<?php

use App\Http\Controllers\AdminController;
use App\Http\Controllers\ExpertController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\VideoController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/login',[UserController::class,'login'])->name('login');
Route::post('/login',[UserController::class,'dologin']);
Route::get('/logout', [UserController::class,'logout'])->middleware('auth');//后台用户注销页面
Route::resource('/user',UserController::class);
Route::resource('/expert',ExpertController::class);
Route::resource('/video',VideoController::class);
Route::get('/lecture',[VideoController::class,'lecture']);//名家讲堂
Route::get('/review',[VideoController::class,'review']);//往期视频
Route::get('/review/info/{id}',[VideoController::class,'show_review']);//视频详情
Route::get('/expert',[ExpertController::class,'experts']);//名家风采
Route::get('/expert/info/{id}',[ExpertController::class,'show_expert']);//专家详情
Route::get('/',[VideoController::class,'index']);

Route::get('/admin',[AdminController::class,'admin'])->middleware('auth');//auth中间件进行身份验证
Route::prefix('admin')->middleware('auth')->group(function (){
    Route::get('/user',[UserController::class,'list']);
    Route::get('/user/add',[UserController::class,'create']);
    Route::post('/user/add',[UserController::class,'store']);
    Route::get('/user/delete/{id}',[UserController::class,'destroy']);
    Route::get('/user/edit/{id}',[UserController::class,'edit']);
    Route::post('/user/edit/{id}',[UserController::class,'update']);
    Route::get('/video',[VideoController::class,'list']);
    Route::get('/video/add',[VideoController::class,'create']);
    Route::post('/video/add',[VideoController::class,'store']);
    Route::post('/video/upload_image',[VideoController::class,'upload']);
    Route::get('/video/edit/{id}',[VideoController::class,'edit']);
    Route::post('/video/edit/{id}',[VideoController::class,'update']);
    Route::get('/video/delete/{id}',[VideoController::class,'delete']);
    Route::get('/expert',[ExpertController::class,'list']);//用户通过 GET 方法请求 /expert 路径时，会执行 ExpertController 类的 list 方法
    Route::get('/expert/add',[ExpertController::class,'create']);
    Route::post('/expert/add',[ExpertController::class,'store']);
    Route::post('/expert/upload_image',[ExpertController::class,'upload']);
    Route::get('/expert/delete/{id}',[ExpertController::class,'delete']);
    Route::get('/expert/edit/{id}',[ExpertController::class,'edit']);
    Route::post('/expert/edit/{id}',[ExpertController::class,'update']);
});

Route::get('/test', function () {
    return view('admin.video_edit');
});
